package com.example.controller;

import com.example.Repository.FileRepository;
import com.example.pojo.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author crt
 */
@RestController
@RequestMapping("file")
public class FileController {

    @Resource
    private FileRepository fileRepository;

    @PostMapping("/list")
    public Result<List<String>> list(@RequestParam Integer trendsId){
        List<String> fileUrlList = fileRepository.list(trendsId);
        return Result.success(fileUrlList);
    }

    @PostMapping("/upload")
    public Result<List<Integer>> upload(MultipartFile[] fileList) throws Exception {
        return fileRepository.upload(fileList);
    }
}
